package com.lhf.personredis.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lhf.personredis.dao.PersonDao;
import com.lhf.personredis.entity.Person;
import com.lhf.personredis.service.PersonService;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class PersonServiceImpl implements PersonService {
    @Resource
    private PersonDao personDao;
    @Override
    @Cacheable
    public PageInfo<Person> getPerson(String name, Integer sex, Integer pageindex) {
        PageHelper.startPage(pageindex,2);
        PageInfo<Person>pageInfos = new PageInfo<>(personDao.getPerson(name,sex));
        System.out.println(">>>>>>>>>>>>>>>>>>>"+pageInfos.getSize());
        return pageInfos;
    }

    @Override
    @Cacheable(key = "#root.args",value = "persons")
    public String getinfo(int id) {
        return personDao.getinfo(id);
    }

}
